//
//  MyViewController.m
//  EquesCat
//
//  Created by Chun Hung Cheung on 2024/12/17.
//

#import "MyViewController.h"
#import "EquesBusiness/YKBusinessFramework.h"
#import "AppDelegate.h"
@interface MyViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *list_tableview;
@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"我的";
    self.list_tableview.backgroundColor = [UIColor whiteColor];
}

-(UITableView*)list_tableview
{
    if (!_list_tableview) {
        _list_tableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _list_tableview.delegate = self;
        _list_tableview.dataSource = self;
        _list_tableview.rowHeight = 50;
        [self.view addSubview:_list_tableview];
        [_list_tableview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view.mas_left);
            make.right.equalTo(self.view.mas_right);
            make.top.equalTo(self.view.mas_top);
            make.bottom.equalTo(self.view.mas_bottom);
        }];
    }
    
    return _list_tableview;
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@""];
    cell.textLabel.text = @"退出登录";
    return cell;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

     YKIPinfo *info = [[YKIPinfo bg_find:@"YKIPinfo" where:nil] firstObject];
     info.auto_login = NO;
    [info bg_saveOrUpdate];
    [YKBusinessFramework equesLogout];
   
    //退出登录时 清除服务器集群信息 防止用户切换服务器后 还是上个服务器集群登录的地址
    [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"colony"];
    [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"colony_addr"];
    
    
    AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
   [delegate login_out];
    
}



@end
